//
// Created by nicemoe on 2021/8/30.
//

#include  <iostream>
#include <string>
#include <cctype>
#include "stacktp.h"
using namespace std;

int main()
{
    Stack<string> st;
    char ch;
    std::string po;
    cout <<"Please enter A to add a purchase order, \n"
        <<"P to process a PO , OR Q TO QUIT.\n";
    while (cin >> ch && toupper(ch) != 'Q') {
        while (cin.get() != '\n'){
            continue;
        }
        if (!isalpha(ch)) {
            cout << '\a';
            continue;
        }
        switch (ch) {
            case 'a':
            case 'A':
                cout<<"Enter a PO number to add: ";
                cin >> po;
                if (st.isFull())
                    cout<< "stack already full\n";
                else
                    st.push(po);
                break;
            case 'P':
            case 'p':
                if (st.isEmpty()) cout <<"stack already empty\n";
                else{
                    st.pop(po);
                    cout <<"PO #" <<po <<" popped\n";
                    break;
                }
        }
        cout <<"Please enter A to add a purchase order, \n"
             <<"P to process a PO , OR Q TO QUIT.\n";
    }
    cout <<"Bye \n";
    return 0;
}
